Less strict tests regarding libtest's stdout
authorMike Lubinets <lubinetsm@yandex.ru>
Tue, 16 May 2017 02:13:43 +0000 (05:13 +0300)
committerMike Lubinets <lubinetsm@yandex.ru>
Tue, 16 May 2017 02:22:52 +0000 (05:22 +0300)
src/doc/guide.md
tests/bench.rs
tests/build-script.rs
tests/cargotest/support/mod.rs
tests/cross-compile.rs
tests/git.rs
tests/path.rs
tests/proc-macro.rs
tests/required-features.rs
tests/test.rs

index 32ff74e8f7d5954b0ce13addc904e11bb127bcbe..f6437ab50fe10cc341ab6f3af96e58d963a645fc 100644 (file)
@@ -368,7 +368,7 @@ class="s1">     Running</span> target/test/hello_world-9c2b65bbb79eabce
 
 running 0 tests
 
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
+test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
 </code></pre>
 
 If our project had tests, we would see more output with the correct number of
index f22ec077c95509f10995ab08c5fc136e6c0d3fd9..e706256189c7cef5fffe8d082308ef7d907065dc 100644 (file)
@@ -44,13 +44,7 @@ fn cargo_bench_simple() {
 [COMPILING] foo v0.5.0 ({})
 [FINISHED] release [optimized] target(s) in [..]
 [RUNNING] target[/]release[/]deps[/]foo-[..][EXE]", p.url()))
-                       .with_stdout("
-running 1 test
-test bench_hello ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-"));
+                       .with_stdout_contains("test bench_hello ... bench: [..]"));
 }
 
 #[test]
@@ -85,13 +79,7 @@ fn bench_bench_implicit() {
 [FINISHED] release [optimized] target(s) in [..]
 [RUNNING] target[/]release[/]deps[/]mybench-[..][EXE]
 ", dir = prj.url()))
-               .with_stdout("
-running 1 test
-test run2 ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-"));
+               .with_stdout_contains("test run2 ... bench: [..]"));
 }
 
 #[test]
@@ -126,13 +114,7 @@ fn bench_bin_implicit() {
 [FINISHED] release [optimized] target(s) in [..]
 [RUNNING] target[/]release[/]deps[/]foo-[..][EXE]
 ", dir = prj.url()))
-               .with_stdout("
-running 1 test
-test run1 ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-"));
+               .with_stdout_contains("test run1 ... bench: [..]"));
 }
 
 #[test]
@@ -162,13 +144,7 @@ fn bench_tarname() {
 [FINISHED] release [optimized] target(s) in [..]
 [RUNNING] target[/]release[/]deps[/]bin2-[..][EXE]
 ", dir = prj.url()))
-               .with_stdout("
-running 1 test
-test run2 ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-"));
+               .with_stdout_contains("test run2 ... bench: [..]"));
 }
 
 #[test]
@@ -190,13 +166,7 @@ fn cargo_bench_verbose() {
 [RUNNING] `rustc [..] src[/]foo.rs [..]`
 [FINISHED] release [optimized] target(s) in [..]
 [RUNNING] `[..]target[/]release[/]deps[/]foo-[..][EXE] hello --bench`", url = p.url()))
-                       .with_stdout("
-running 1 test
-test bench_hello ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-"));
+                       .with_stdout_contains("test bench_hello ... bench: [..]"));
 }
 
 #[test]
@@ -266,9 +236,7 @@ fn cargo_bench_failing_test() {
                 execs().with_stdout("hello\n"));
 
     assert_that(p.cargo("bench"),
-                execs().with_stdout_contains("
-running 1 test
-test bench_hello ... ")
+                execs().with_stdout_contains("test bench_hello ... ")
                        .with_stderr_contains(format!("\
 [COMPILING] foo v0.5.0 ({})
 [FINISHED] release [optimized] target(s) in [..]
@@ -327,19 +295,8 @@ fn bench_with_lib_dep() {
 [FINISHED] release [optimized] target(s) in [..]
 [RUNNING] target[/]release[/]deps[/]foo-[..][EXE]
 [RUNNING] target[/]release[/]deps[/]baz-[..][EXE]", p.url()))
-                       .with_stdout("
-running 1 test
-test lib_bench ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-
-running 1 test
-test bin_bench ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-"))
+                       .with_stdout_contains("test lib_bench ... bench: [..]")                     
+                       .with_stdout_contains("test bin_bench ... bench: [..]"));
 }
 
 #[test]
@@ -390,13 +347,7 @@ fn bench_with_deep_lib_dep() {
 [COMPILING] bar v0.0.1 ({dir})
 [FINISHED] release [optimized] target(s) in [..]
 [RUNNING] target[/]release[/]deps[/]bar-[..][EXE]", dir = p.url()))
-                       .with_stdout("
-running 1 test
-test bar_bench ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-"));
+                       .with_stdout_contains("test bar_bench ... bench: [..]"));
 }
 
 #[test]
@@ -437,19 +388,8 @@ fn external_bench_explicit() {
 [FINISHED] release [optimized] target(s) in [..]
 [RUNNING] target[/]release[/]deps[/]foo-[..][EXE]
 [RUNNING] target[/]release[/]deps[/]bench-[..][EXE]", p.url()))
-                       .with_stdout("
-running 1 test
-test internal_bench ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-
-running 1 test
-test external_bench ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-"))
+                       .with_stdout_contains("test internal_bench ... bench: [..]")
+                       .with_stdout_contains("test external_bench ... bench: [..]"));
 }
 
 #[test]
@@ -487,19 +427,8 @@ fn external_bench_implicit() {
 [FINISHED] release [optimized] target(s) in [..]
 [RUNNING] target[/]release[/]deps[/]foo-[..][EXE]
 [RUNNING] target[/]release[/]deps[/]external-[..][EXE]", p.url()))
-                       .with_stdout("
-running 1 test
-test internal_bench ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-
-running 1 test
-test external_bench ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-"))
+                       .with_stdout_contains("test internal_bench ... bench: [..]")
+                       .with_stdout_contains("test external_bench ... bench: [..]"));
 }
 
 #[test]
@@ -547,25 +476,13 @@ fn pass_through_command_line() {
 [COMPILING] foo v0.0.1 ({dir})
 [FINISHED] release [optimized] target(s) in [..]
 [RUNNING] target[/]release[/]deps[/]foo-[..][EXE]", dir = p.url()))
-                .with_stdout("
-running 1 test
-test bar ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-"));
+                .with_stdout_contains("test bar ... bench: [..]"));
 
     assert_that(p.cargo("bench").arg("foo"),
                 execs().with_status(0)
                        .with_stderr("[FINISHED] release [optimized] target(s) in [..]
 [RUNNING] target[/]release[/]deps[/]foo-[..][EXE]")
-                       .with_stdout("
-running 1 test
-test foo ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-"));
+                       .with_stdout_contains("test foo ... bench: [..]"));
 }
 
 // Regression test for running cargo-bench twice with
@@ -630,19 +547,7 @@ fn lib_bin_same_name() {
 [FINISHED] release [optimized] target(s) in [..]
 [RUNNING] target[/]release[/]deps[/]foo-[..][EXE]
 [RUNNING] target[/]release[/]deps[/]foo-[..][EXE]", p.url()))
-                       .with_stdout("
-running 1 test
-test [..] ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-
-running 1 test
-test [..] ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-"))
+                       .with_stdout_contains_n("test [..] ... bench: [..]", 2));
 }
 
 #[test]
@@ -684,19 +589,8 @@ fn lib_with_standard_name() {
 [FINISHED] release [optimized] target(s) in [..]
 [RUNNING] target[/]release[/]deps[/]syntax-[..][EXE]
 [RUNNING] target[/]release[/]deps[/]bench-[..][EXE]", dir = p.url()))
-                       .with_stdout("
-running 1 test
-test foo_bench ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-
-running 1 test
-test bench ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-"));
+                       .with_stdout_contains("test foo_bench ... bench: [..]")
+                       .with_stdout_contains("test bench ... bench: [..]"));
 }
 
 #[test]
@@ -735,13 +629,7 @@ fn lib_with_standard_name2() {
 [COMPILING] syntax v0.0.1 ({dir})
 [FINISHED] release [optimized] target(s) in [..]
 [RUNNING] target[/]release[/]deps[/]syntax-[..][EXE]", dir = p.url()))
-                       .with_stdout("
-running 1 test
-test bench ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-"));
+                       .with_stdout_contains("test bench ... bench: [..]"));
 }
 
 #[test]
@@ -806,19 +694,8 @@ fn bench_dylib() {
 [FINISHED] release [optimized] target(s) in [..]
 [RUNNING] `[..]target[/]release[/]deps[/]foo-[..][EXE] --bench`
 [RUNNING] `[..]target[/]release[/]deps[/]bench-[..][EXE] --bench`", dir = p.url()))
-                       .with_stdout("
-running 1 test
-test foo ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-
-running 1 test
-test foo ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-"));
+                       .with_stdout_contains_n("test foo ... bench: [..]", 2));
+    
     p.root().move_into_the_past();
     assert_that(p.cargo("bench").arg("-v"),
                 execs().with_status(0)
@@ -828,19 +705,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
 [FINISHED] release [optimized] target(s) in [..]
 [RUNNING] `[..]target[/]release[/]deps[/]foo-[..][EXE] --bench`
 [RUNNING] `[..]target[/]release[/]deps[/]bench-[..][EXE] --bench`", dir = p.url()))
-                       .with_stdout("
-running 1 test
-test foo ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-
-running 1 test
-test foo ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-"));
+                       .with_stdout_contains_n("test foo ... bench: [..]", 2));
 }
 
 #[test]
@@ -869,25 +734,13 @@ fn bench_twice_with_build_cmd() {
 [COMPILING] foo v0.0.1 ({dir})
 [FINISHED] release [optimized] target(s) in [..]
 [RUNNING] target[/]release[/]deps[/]foo-[..][EXE]", dir = p.url()))
-                       .with_stdout("
-running 1 test
-test foo ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-"));
+                       .with_stdout_contains("test foo ... bench: [..]"));
 
     assert_that(p.cargo("bench"),
                 execs().with_status(0)
                        .with_stderr("[FINISHED] release [optimized] target(s) in [..]
 [RUNNING] target[/]release[/]deps[/]foo-[..][EXE]")
-                       .with_stdout("
-running 1 test
-test foo ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-"));
+                       .with_stdout_contains("test foo ... bench: [..]"));
 }
 
 #[test]
@@ -956,19 +809,8 @@ fn bench_with_examples() {
 [RUNNING] `{dir}[/]target[/]release[/]deps[/]testbench-[..][EXE] --bench`
 [RUNNING] `{dir}[/]target[/]release[/]deps[/]testb1-[..][EXE] --bench`",
                 dir = p.root().display(), url = p.url()))
-                       .with_stdout("
-running 1 test
-test bench_bench1 ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-
-running 1 test
-test bench_bench2 ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-"));
+                       .with_stdout_contains("test bench_bench1 ... bench: [..]")
+                       .with_stdout_contains("test bench_bench2 ... bench: [..]"));
 }
 
 #[test]
@@ -1003,13 +845,7 @@ fn test_a_bench() {
 [COMPILING] foo v0.1.0 ([..])
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]b-[..][EXE]")
-                       .with_stdout("
-running 1 test
-test foo ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains("test foo ... ok"));
 }
 
 #[test]
@@ -1113,20 +949,10 @@ fn test_bench_multiple_packages() {
                 execs().with_status(0)
                        .with_stderr_contains("\
 [RUNNING] target[/]release[/]deps[/]bbaz-[..][EXE]")
-                       .with_stdout_contains("
-running 1 test
-test bench_baz ... bench:           0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-")
+                       .with_stdout_contains("test bench_baz ... bench: [..]")
                        .with_stderr_contains("\
 [RUNNING] target[/]release[/]deps[/]bbar-[..][EXE]")
-                       .with_stdout_contains("
-running 1 test
-test bench_bar ... bench:           0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-"));
+                       .with_stdout_contains("test bench_bar ... bench: [..]"));
 }
 
 #[test]
@@ -1179,20 +1005,10 @@ fn bench_all_workspace() {
                 execs().with_status(0)
                        .with_stderr_contains("\
 [RUNNING] target[/]release[/]deps[/]bar-[..][EXE]")
-                       .with_stdout_contains("
-running 1 test
-test bench_bar ... bench:           0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-")
-                        .with_stderr_contains("\
+                       .with_stdout_contains("test bench_bar ... bench: [..]")
+                       .with_stderr_contains("\
 [RUNNING] target[/]release[/]deps[/]foo-[..][EXE]")
-                       .with_stdout_contains("
-running 1 test
-test bench_foo ... bench:           0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-"));
+                       .with_stdout_contains("test bench_foo ... bench: [..]"));
 }
 
 #[test]
@@ -1245,19 +1061,9 @@ fn bench_all_virtual_manifest() {
                 execs().with_status(0)
                        .with_stderr_contains("\
 [RUNNING] target[/]release[/]deps[/]bar-[..][EXE]")
-                       .with_stdout_contains("
-running 1 test
-test bench_bar ... bench:           0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-")
-                        .with_stderr_contains("\
+                       .with_stdout_contains("test bench_bar ... bench: [..]")
+                       .with_stderr_contains("\
 [RUNNING] target[/]release[/]deps[/]foo-[..][EXE]")
-                       .with_stdout_contains("
-running 1 test
-test bench_foo ... bench:           0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-"));
+                       .with_stdout_contains("test bench_foo ... bench: [..]"));
 }
 
index 7356af284c174e1ca84c7f9f7528c10d2b742bfb..ba3d6a0367f8fbc4fa83d8752282f2a6ace859eb 100644 (file)
@@ -502,17 +502,7 @@ fn testing_and_such() {
 [RUNNING] `[..][/]foo-[..][EXE]`
 [DOCTEST] foo
 [RUNNING] `rustdoc --test [..]`")
-                       .with_stdout("
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains_n("running 0 tests", 2));
 
     println!("doc");
     assert_that(p.cargo("doc").arg("-v"),
@@ -1392,25 +1382,9 @@ fn cfg_test() {
 [RUNNING] `[..][/]test-[..][EXE]`
 [DOCTEST] foo
 [RUNNING] [..] --cfg foo[..]", dir = p.url()))
-                       .with_stdout("
-running 1 test
-test test_foo ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 1 test
-test test_bar ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 1 test
-test [..] ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains("test test_foo ... ok")
+                       .with_stdout_contains("test test_bar ... ok")
+                       .with_stdout_contains_n("test [..] ... ok", 3));
 }
 
 #[test]
@@ -1509,25 +1483,9 @@ fn cfg_override_test() {
 [RUNNING] `[..][/]test-[..][EXE]`
 [DOCTEST] foo
 [RUNNING] [..] --cfg foo[..]", dir = p.url()))
-                       .with_stdout("
-running 1 test
-test test_foo ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 1 test
-test test_bar ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 1 test
-test [..] ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains("test test_foo ... ok")
+                       .with_stdout_contains("test test_bar ... ok")
+                       .with_stdout_contains_n("test [..] ... ok", 3));
 }
 
 #[test]
@@ -1641,23 +1599,8 @@ fn env_test() {
 [RUNNING] `[..][/]test-[..][EXE]`
 [DOCTEST] foo
 [RUNNING] [..] --crate-name foo[..]", dir = p.url()))
-                       .with_stdout("
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 1 test
-test test_foo ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains_n("running 0 tests", 2)
+                       .with_stdout_contains("test test_foo ... ok"));
 }
 
 #[test]
@@ -1734,12 +1677,7 @@ fn flags_go_into_tests() {
 [RUNNING] `rustc [..] tests[/]foo.rs [..] -L test[..]`
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] `[..][/]foo-[..][EXE]`")
-                       .with_stdout("
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains("running 0 tests"));
 
     assert_that(p.cargo("test").arg("-v").arg("-pb").arg("--lib"),
                 execs().with_status(0)
@@ -1749,12 +1687,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
 [RUNNING] `rustc [..] b[/]src[/]lib.rs [..] -L test[..]`
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] `[..][/]b-[..][EXE]`")
-                       .with_stdout("
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains("running 0 tests"));
 }
 
 #[test]
index 2e3e6d21c8c1c2828cac1ee1825c1ca715df2572..63b441b822b50e867633f09a19ac4b060f7d5038 100644 (file)
@@ -337,6 +337,7 @@ pub struct Execs {
     expect_exit_code: Option<i32>,
     expect_stdout_contains: Vec<String>,
     expect_stderr_contains: Vec<String>,
+    expect_stdout_contains_n: Vec<(String, usize)>,
     expect_stdout_not_contains: Vec<String>,
     expect_stderr_not_contains: Vec<String>,
     expect_json: Option<Vec<Value>>,
@@ -368,6 +369,11 @@ impl Execs {
         self
     }
 
+    pub fn with_stdout_contains_n<S: ToString>(mut self, expected: S, number: usize) -> Execs {
+        self.expect_stdout_contains_n.push((expected.to_string(), number));
+        self
+    }
+
     pub fn with_stdout_does_not_contain<S: ToString>(mut self, expected: S) -> Execs {
         self.expect_stdout_not_contains.push(expected.to_string());
         self
@@ -416,6 +422,10 @@ impl Execs {
             self.match_std(Some(expect), &actual.stderr, "stderr",
                            &actual.stdout, MatchKind::Partial)?;
         }
+        for &(ref expect, number) in self.expect_stdout_contains_n.iter() {
+            self.match_std(Some(&expect), &actual.stdout, "stdout",
+                           &actual.stderr, MatchKind::PartialN(number))?;
+        }
         for expect in self.expect_stdout_not_contains.iter() {
             self.match_std(Some(expect), &actual.stdout, "stdout",
                            &actual.stderr, MatchKind::NotPresent)?;
@@ -493,6 +503,26 @@ impl Execs {
                                      {}", out,
                                      actual))
             }
+            MatchKind::PartialN(number) => {
+                let mut a = actual.lines();
+                let e = out.lines();
+
+                let mut matches = 0;
+
+                while let Some(..) = { 
+                    if self.diff_lines(a.clone(), e.clone(), true).is_empty() {
+                        matches += 1;
+                    }
+                    a.next()
+                } {}
+                
+                ham::expect(matches == number,
+                            format!("expected to find {} occurences:\n\
+                                     {}\n\n\
+                                     did not find in output:\n\
+                                     {}", number, out,
+                                     actual))
+            }
             MatchKind::NotPresent => {
                 ham::expect(!actual.contains(out),
                             format!("expected not to find:\n\
@@ -554,6 +584,7 @@ impl Execs {
 enum MatchKind {
     Exact,
     Partial,
+    PartialN(usize),
     NotPresent,
 }
 
@@ -718,6 +749,7 @@ pub fn execs() -> Execs {
         expect_exit_code: None,
         expect_stdout_contains: Vec::new(),
         expect_stderr_contains: Vec::new(),
+        expect_stdout_contains_n: Vec::new(),
         expect_stdout_not_contains: Vec::new(),
         expect_stderr_not_contains: Vec::new(),
         expect_json: None,
index d4c134fc3e054dff3f2befb723e8d596c95f0a30..3054185b6672b1f98bdbfa87952340695ed058e3 100644 (file)
@@ -550,19 +550,8 @@ fn cross_tests() {
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]{triple}[/]debug[/]deps[/]foo-[..][EXE]
 [RUNNING] target[/]{triple}[/]debug[/]deps[/]bar-[..][EXE]", foo = p.url(), triple = target))
-                       .with_stdout("
-running 1 test
-test test_foo ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 1 test
-test test ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains("test test_foo ... ok")
+                       .with_stdout_contains("test test ... ok"));
 }
 
 #[test]
@@ -1114,18 +1103,6 @@ fn cross_test_dylib() {
 [RUNNING] target[/]{arch}[/]debug[/]deps[/]foo-[..][EXE]
 [RUNNING] target[/]{arch}[/]debug[/]deps[/]test-[..][EXE]",
                         dir = p.url(), arch = alternate()))
-                       .with_stdout("
-running 1 test
-test foo ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 1 test
-test foo ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains_n("test foo ... ok", 2));
 
 }
index 07c4996cb4225e480dff0ec6d72a651f1d64f5e0..615e601846be6fd12c82794e765b7d6e2e077565 100644 (file)
@@ -1158,13 +1158,7 @@ fn dev_deps_with_testing() {
 [COMPILING] [..] v0.5.0 ([..]
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]")
-                       .with_stdout("
-running 1 test
-test tests::foo ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains("test tests::foo ... ok"));
 }
 
 #[test]
index 52e117d762b85c283eea0570ad14450bff4eea3a..16335e2168a5e87cd7b2a0826af2a37681c66c50 100644 (file)
@@ -193,12 +193,7 @@ fn cargo_compile_with_root_dev_deps_with_testing() {
 [COMPILING] [..] v0.5.0 ([..])
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]")
-                       .with_stdout("
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains("running 0 tests"));
 }
 
 #[test]
@@ -800,12 +795,7 @@ fn dev_deps_no_rebuild_lib() {
 [COMPILING] [..] v0.5.0 ({url}[..])
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]", url = p.url()))
-                       .with_stdout("
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains("running 0 tests"));
 }
 
 #[test]
index 1b44e0ed32eba57a3d0da2a535369cb1e2676b35..ee04a74e1dcd6cd9bf509211655240e28daf9e98 100644 (file)
@@ -217,17 +217,6 @@ fn a() {
 
     assert_that(foo.cargo_process("test"),
                 execs().with_status(0)
-                       .with_stdout_contains("\
-running 1 test
-test a ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-").with_stdout_contains("\
-running 1 test
-test [..] ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains("test a ... ok")
+                       .with_stdout_contains_n("test [..] ... ok", 2));
 }
index 38edefdefdbd0493bccd5f3f2aa0ccb43d74d373..3e2ad26eecd44fb90750c27f0cffd8ae2729461d 100644 (file)
@@ -268,13 +268,7 @@ fn test_default_features() {
 [COMPILING] foo v0.0.1 ({})
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]", p.url()))
-                .with_stdout("
-running 1 test
-test test ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                .with_stdout_contains("test test ... ok"));
 
     assert_that(p.cargo("test").arg("--no-default-features"),
                 execs().with_status(0).with_stderr(format!("\
@@ -285,13 +279,7 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
                 execs().with_status(0).with_stderr(format!("\
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]"))
-                .with_stdout("
-running 1 test
-test test ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                .with_stdout_contains("test test ... ok"));
 
     assert_that(p.cargo("test").arg("--test=foo").arg("--no-default-features"),
                 execs().with_status(101).with_stderr("\
@@ -324,13 +312,7 @@ fn test_arg_features() {
 [COMPILING] foo v0.0.1 ({})
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]", p.url()))
-                .with_stdout("
-running 1 test
-test test ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                .with_stdout_contains("test test ... ok"));
 }
 
 #[test]
@@ -365,13 +347,7 @@ fn test_multiple_required_features() {
 [COMPILING] foo v0.0.1 ({})
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]foo_2-[..][EXE]", p.url()))
-                .with_stdout("
-running 1 test
-test test ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                .with_stdout_contains("test test ... ok"));
 
     assert_that(p.cargo("test").arg("--features").arg("c"),
                 execs().with_status(0).with_stderr(format!("\
@@ -379,19 +355,7 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]foo_1-[..][EXE]
 [RUNNING] target[/]debug[/]deps[/]foo_2-[..][EXE]", p.url()))
-                .with_stdout("
-running 1 test
-test test ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 1 test
-test test ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                .with_stdout_contains_n("test test ... ok", 2));
 
     assert_that(p.cargo("test").arg("--no-default-features"),
                 execs().with_status(0).with_stderr(format!("\
@@ -434,13 +398,7 @@ fn bench_default_features() {
 [COMPILING] foo v0.0.1 ({})
 [FINISHED] release [optimized] target(s) in [..]
 [RUNNING] target[/]release[/]deps[/]foo-[..][EXE]", p.url()))
-                .with_stdout("
-running 1 test
-test bench ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-"));
+                .with_stdout_contains("test bench ... bench: [..]"));
 
     assert_that(p.cargo("bench").arg("--no-default-features"),
                 execs().with_status(0).with_stderr(format!("\
@@ -451,13 +409,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
                 execs().with_status(0).with_stderr(format!("\
 [FINISHED] release [optimized] target(s) in [..]
 [RUNNING] target[/]release[/]deps[/]foo-[..][EXE]"))
-                .with_stdout("
-running 1 test
-test bench ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-"));
+                .with_stdout_contains("test bench ... bench: [..]"));
 
     assert_that(p.cargo("bench").arg("--bench=foo").arg("--no-default-features"),
                 execs().with_status(101).with_stderr("\
@@ -500,13 +452,7 @@ fn bench_arg_features() {
 [COMPILING] foo v0.0.1 ({})
 [FINISHED] release [optimized] target(s) in [..]
 [RUNNING] target[/]release[/]deps[/]foo-[..][EXE]", p.url()))
-                .with_stdout("
-running 1 test
-test bench ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-"));
+                .with_stdout_contains("test bench ... bench: [..]"));
 }
 
 #[test]
@@ -557,13 +503,7 @@ fn bench_multiple_required_features() {
 [COMPILING] foo v0.0.1 ({})
 [FINISHED] release [optimized] target(s) in [..]
 [RUNNING] target[/]release[/]deps[/]foo_2-[..][EXE]", p.url()))
-                .with_stdout("
-running 1 test
-test bench ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-"));
+                .with_stdout_contains("test bench ... bench: [..]"));
 
     assert_that(p.cargo("bench").arg("--features").arg("c"),
                 execs().with_status(0).with_stderr(format!("\
@@ -571,19 +511,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
 [FINISHED] release [optimized] target(s) in [..]
 [RUNNING] target[/]release[/]deps[/]foo_1-[..][EXE]
 [RUNNING] target[/]release[/]deps[/]foo_2-[..][EXE]", p.url()))
-                .with_stdout("
-running 1 test
-test bench ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-
-running 1 test
-test bench ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-"));
+                .with_stdout_contains_n("test bench ... bench: [..]", 2));
 
     assert_that(p.cargo("bench").arg("--no-default-features"),
                 execs().with_status(0).with_stderr(format!("\
@@ -815,13 +743,7 @@ fn dep_feature_in_toml() {
 [COMPILING] foo v0.0.1 ({})
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]", p.url()))
-                .with_stdout("
-running 1 test
-test test ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                .with_stdout_contains("test test ... ok"));
 
     // bench
     if is_nightly() {
@@ -831,13 +753,7 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
 [COMPILING] foo v0.0.1 ({0})
 [FINISHED] release [optimized] target(s) in [..]
 [RUNNING] target[/]release[/]deps[/]foo-[..][EXE]", p.url()))
-                    .with_stdout("
-running 1 test
-test bench ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-"));
+                    .with_stdout_contains("test bench ... bench: [..]"));
     }
 
     // install
@@ -934,13 +850,7 @@ Consider enabling them by passing e.g. `--features=\"bar/a\"`
 [COMPILING] foo v0.0.1 ({})
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]", p.url()))
-                .with_stdout("
-running 1 test
-test test ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                .with_stdout_contains("test test ... ok"));
 
     // bench
     if is_nightly() {
@@ -955,13 +865,7 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
 [COMPILING] foo v0.0.1 ({0})
 [FINISHED] release [optimized] target(s) in [..]
 [RUNNING] target[/]release[/]deps[/]foo-[..][EXE]", p.url()))
-                    .with_stdout("
-running 1 test
-test bench ... bench: [..] 0 ns/iter (+/- 0)
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
-
-"));
+                    .with_stdout_contains("test bench ... bench: [..]"));
     }
 
     // install
@@ -1007,12 +911,7 @@ fn test_skips_compiling_bin_with_missing_required_features() {
 [COMPILING] foo v0.0.1 ({})
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]", p.url()))
-                .with_stdout("
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                .with_stdout_contains("running 0 tests"));
 
     assert_that(p.cargo("test").arg("--features").arg("a").arg("-j").arg("1"),
                 execs().with_status(101).with_stderr_contains(format!("\
@@ -1025,12 +924,7 @@ error[E0463]: can't find crate for `bar`", p.url())));
 [COMPILING] foo v0.0.1 ({})
 [FINISHED] release [optimized] target(s) in [..]
 [RUNNING] target[/]release[/]deps[/]foo-[..][EXE]", p.url()))
-                    .with_stdout("
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                    .with_stdout_contains("running 0 tests"));
 
         assert_that(p.cargo("bench").arg("--features").arg("a").arg("-j").arg("1"),
                     execs().with_status(101).with_stderr_contains(format!("\
index fbbf02667e19a9b232f284f065795d4d23ea803b..473e63472cfa224eaf4ef29b417b467b3ef343bf 100644 (file)
@@ -42,13 +42,7 @@ fn cargo_test_simple() {
 [COMPILING] foo v0.5.0 ({})
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]", p.url()))
-                       .with_stdout("
-running 1 test
-test test_hello ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains("test test_hello ... ok"));
 }
 
 #[test]
@@ -97,24 +91,8 @@ fn cargo_test_release() {
 [RUNNING] `[..]target[/]release[/]deps[/]test-[..][EXE]`
 [DOCTEST] foo
 [RUNNING] `rustdoc --test [..]lib.rs[..]`", dir = p.url()))
-                       .with_stdout("
-running 1 test
-test test ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 1 test
-test test ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains_n("test test ... ok", 2)
+                       .with_stdout_contains("running 0 tests"));
 }
 
 #[test]
@@ -167,13 +145,7 @@ fn cargo_test_verbose() {
 [RUNNING] `rustc [..] src[/]foo.rs [..]`
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] `[..]target[/]debug[/]deps[/]foo-[..][EXE] hello`", url = p.url()))
-                       .with_stdout("
-running 1 test
-test test_hello ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains("test test_hello ... ok"));
 }
 
 #[test]
@@ -250,8 +222,6 @@ failures:
                        .with_stdout_contains("\
 failures:
     test_hello
-
-test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured
 ")
                        .with_status(101));
 }
@@ -283,12 +253,8 @@ fn cargo_test_failing_test_in_test() {
 [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]
 [RUNNING] target[/]debug[/]deps[/]footest-[..][EXE]
 [ERROR] test failed, to rerun pass '--test footest'", url = p.url()))
-                       .with_stdout_contains("
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-
+                       .with_stdout_contains("running 0 tests")
+                       .with_stdout_contains("\
 running 1 test
 test test_hello ... FAILED
 
@@ -301,8 +267,6 @@ failures:
                        .with_stdout_contains("\
 failures:
     test_hello
-
-test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured
 ")
                        .with_status(101));
 }
@@ -323,8 +287,7 @@ fn cargo_test_failing_test_in_lib() {
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]
 [ERROR] test failed, to rerun pass '--lib'", url = p.url()))
-                       .with_stdout_contains("
-running 1 test
+                       .with_stdout_contains("\
 test test_hello ... FAILED
 
 failures:
@@ -336,8 +299,6 @@ failures:
                        .with_stdout_contains("\
 failures:
     test_hello
-
-test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured
 ")
                        .with_status(101));
 }
@@ -384,25 +345,9 @@ fn test_with_lib_dep() {
 [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]
 [RUNNING] target[/]debug[/]deps[/]baz-[..][EXE]
 [DOCTEST] foo", p.url()))
-                       .with_stdout("
-running 1 test
-test lib_test ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 1 test
-test bin_test ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 1 test
-test [..] ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"))
+                       .with_stdout_contains("test lib_test ... ok")
+                       .with_stdout_contains("test bin_test ... ok")
+                       .with_stdout_contains_n("test [..] ... ok", 3));
 }
 
 #[test]
@@ -452,19 +397,8 @@ fn test_with_deep_lib_dep() {
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[..]
 [DOCTEST] bar", dir = p.url()))
-                       .with_stdout("
-running 1 test
-test bar_test ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 1 test
-test [..] ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains("test bar_test ... ok")
+                       .with_stdout_contains_n("test [..] ... ok", 2));
 }
 
 #[test]
@@ -500,24 +434,9 @@ fn external_test_explicit() {
 [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]
 [RUNNING] target[/]debug[/]deps[/]test-[..][EXE]
 [DOCTEST] foo", p.url()))
-                       .with_stdout("
-running 1 test
-test internal_test ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 1 test
-test external_test ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-"))
+                       .with_stdout_contains("test internal_test ... ok")
+                       .with_stdout_contains("test external_test ... ok")
+                       .with_stdout_contains("running 0 tests"));
 }
 
 #[test]
@@ -571,24 +490,9 @@ fn external_test_implicit() {
 [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]
 [RUNNING] target[/]debug[/]deps[/]external-[..][EXE]
 [DOCTEST] foo", p.url()))
-                       .with_stdout("
-running 1 test
-test internal_test ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 1 test
-test external_test ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-"))
+                       .with_stdout_contains("test internal_test ... ok")
+                       .with_stdout_contains("test external_test ... ok")
+                       .with_stdout_contains("running 0 tests"));
 }
 
 #[test]
@@ -630,18 +534,8 @@ fn pass_through_command_line() {
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]
 [DOCTEST] foo", dir = p.url()))
-                       .with_stdout("
-running 1 test
-test bar ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains("test bar ... ok")
+                       .with_stdout_contains("running 0 tests"));
 
     assert_that(p.cargo("test").arg("foo"),
                 execs().with_status(0)
@@ -649,18 +543,8 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]
 [DOCTEST] foo")
-                       .with_stdout("
-running 1 test
-test foo ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains("test foo ... ok")
+                       .with_stdout_contains("running 0 tests"));
 }
 
 // Regression test for running cargo-test twice with
@@ -715,24 +599,8 @@ fn lib_bin_same_name() {
 [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]
 [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]
 [DOCTEST] foo", p.url()))
-                       .with_stdout("
-running 1 test
-test [..] ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 1 test
-test [..] ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-"))
+                       .with_stdout_contains_n("test [..] ... ok", 2)
+                       .with_stdout_contains("running 0 tests"));
 }
 
 #[test]
@@ -768,25 +636,9 @@ fn lib_with_standard_name() {
 [RUNNING] target[/]debug[/]deps[/]syntax-[..][EXE]
 [RUNNING] target[/]debug[/]deps[/]test-[..][EXE]
 [DOCTEST] syntax", dir = p.url()))
-                       .with_stdout("
-running 1 test
-test foo_test ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 1 test
-test test ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 1 test
-test [..] ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains("test foo_test ... ok")
+                       .with_stdout_contains("test test ... ok")
+                       .with_stdout_contains_n("test [..] ... ok", 3));
 }
 
 #[test]
@@ -821,13 +673,7 @@ fn lib_with_standard_name2() {
 [COMPILING] syntax v0.0.1 ({dir})
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]syntax-[..][EXE]", dir = p.url()))
-                       .with_stdout("
-running 1 test
-test test ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains("test test ... ok"));
 }
 
 #[test]
@@ -861,13 +707,7 @@ fn lib_without_name() {
 [COMPILING] syntax v0.0.1 ({dir})
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]syntax-[..][EXE]", dir = p.url()))
-                       .with_stdout("
-running 1 test
-test test ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains("test test ... ok"));
 }
 
 #[test]
@@ -1120,19 +960,8 @@ fn test_dylib() {
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]
 [RUNNING] target[/]debug[/]deps[/]test-[..][EXE]", dir = p.url()))
-                       .with_stdout("
-running 1 test
-test foo ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
+                       .with_stdout_contains_n("test foo ... ok", 2));
 
-
-running 1 test
-test foo ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
     p.root().move_into_the_past();
     assert_that(p.cargo("test"),
                 execs().with_status(0)
@@ -1140,20 +969,7 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]
 [RUNNING] target[/]debug[/]deps[/]test-[..][EXE]")
-                       .with_stdout("
-running 1 test
-test foo ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 1 test
-test foo ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
-
+                       .with_stdout_contains_n("test foo ... ok", 2));
 }
 
 #[test]
@@ -1179,18 +995,8 @@ fn test_twice_with_build_cmd() {
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]
 [DOCTEST] foo", dir = p.url()))
-                       .with_stdout("
-running 1 test
-test foo ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains("test foo ... ok")
+                       .with_stdout_contains("running 0 tests"));
 
     assert_that(p.cargo("test"),
                 execs().with_status(0)
@@ -1198,18 +1004,8 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]
 [DOCTEST] foo")
-                       .with_stdout("
-running 1 test
-test foo ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains("test foo ... ok")
+                       .with_stdout_contains("running 0 tests"));
 }
 
 #[test]
@@ -1233,18 +1029,8 @@ fn test_then_build() {
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]
 [DOCTEST] foo", dir = p.url()))
-                       .with_stdout("
-running 1 test
-test foo ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains("test foo ... ok")
+                       .with_stdout_contains("running 0 tests"));
 
     assert_that(p.cargo("build"),
                 execs().with_status(0)
@@ -1300,13 +1086,7 @@ fn test_run_specific_bin_target() {
 [COMPILING] foo v0.0.1 ({dir})
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]bin2-[..][EXE]", dir = prj.url()))
-                       .with_stdout("
-running 1 test
-test test2 ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains("test test2 ... ok"));
 }
 
 #[test]
@@ -1335,13 +1115,7 @@ fn test_run_implicit_bin_target() {
 [COMPILING] foo v0.0.1 ({dir})
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]mybin-[..][EXE]", dir = prj.url()))
-                       .with_stdout("
-running 1 test
-test test_in_bin ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains("test test_in_bin ... ok"));
 }
 
 #[test]
@@ -1364,13 +1138,7 @@ fn test_run_specific_test_target() {
 [COMPILING] foo v0.0.1 ({dir})
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]b-[..][EXE]", dir = prj.url()))
-                       .with_stdout("
-running 1 test
-test test_b ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains("test test_b ... ok"));
 }
 
 #[test]
@@ -1399,13 +1167,7 @@ fn test_run_implicit_test_target() {
 [COMPILING] foo v0.0.1 ({dir})
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]mytest-[..][EXE]", dir = prj.url()))
-                       .with_stdout("
-running 1 test
-test test_in_test ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains("test test_in_test ... ok"));
 }
 
 #[test]
@@ -1434,13 +1196,7 @@ fn test_run_implicit_bench_target() {
 [COMPILING] foo v0.0.1 ({dir})
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]mybench-[..][EXE]", dir = prj.url()))
-                       .with_stdout("
-running 1 test
-test test_in_bench ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains("test test_in_bench ... ok"));
 }
 
 #[test]
@@ -1554,17 +1310,7 @@ fn selective_testing() {
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]d1-[..][EXE]
 [RUNNING] target[/]debug[/]deps[/]d1-[..][EXE]", dir = p.url()))
-                       .with_stdout("
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains_n("running 0 tests", 2));
 
     println!("d2");
     assert_that(p.cargo("test").arg("-p").arg("d2"),
@@ -1574,17 +1320,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]d2-[..][EXE]
 [RUNNING] target[/]debug[/]deps[/]d2-[..][EXE]", dir = p.url()))
-                       .with_stdout("
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains_n("running 0 tests", 2));
 
     println!("whole");
     assert_that(p.cargo("test"),
@@ -1593,12 +1329,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
 [COMPILING] foo v0.0.1 ({dir})
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]", dir = p.url()))
-                       .with_stdout("
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains("running 0 tests"));
 }
 
 #[test]
@@ -1756,17 +1487,7 @@ fn selective_testing_with_docs() {
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]d1[..][EXE]
 [DOCTEST] d1", dir = p.url()))
-                       .with_stdout("
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains_n("running 0 tests", 2));
 }
 
 #[test]
@@ -1939,18 +1660,8 @@ fn doctest_feature() {
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]foo[..][EXE]
 [DOCTEST] foo")
-                       .with_stdout("
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 1 test
-test [..] ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"))
+                       .with_stdout_contains("running 0 tests")
+                       .with_stdout_contains("test [..] ... ok"));
 }
 
 #[test]
@@ -2025,12 +1736,7 @@ fn filter_no_doc_tests() {
 [COMPILING] foo v0.0.1 ([..])
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]foo[..][EXE]")
-                       .with_stdout("
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains("running 0 tests"));
 }
 
 #[test]
@@ -2059,13 +1765,7 @@ fn dylib_doctest() {
 [COMPILING] foo v0.0.1 ([..])
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [DOCTEST] foo")
-                       .with_stdout("
-running 1 test
-test [..] ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                       .with_stdout_contains("test [..] ... ok"));
 }
 
 #[test]
@@ -2130,18 +1830,8 @@ fn cyclic_dev_dep_doc_test() {
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]foo[..][EXE]
 [DOCTEST] foo")
-                       .with_stdout("
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 1 test
-test [..] ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"))
+                       .with_stdout_contains("running 0 tests")
+                       .with_stdout_contains("test [..] ... ok"));
 }
 
 #[test]
@@ -2223,31 +1913,13 @@ fn no_fail_fast() {
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]
 [RUNNING] target[/]debug[/]deps[/]test_add_one-[..][EXE]")
-                       .with_stdout_contains("
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-
-")
+                       .with_stdout_contains("running 0 tests")
                        .with_stderr_contains("\
 [RUNNING] target[/]debug[/]deps[/]test_sub_one-[..][EXE]
 [DOCTEST] foo")
-                       .with_stdout_contains("\
-test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured
-
-
-running 1 test
-test sub_one_test ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-
-running 1 test
-test [..] ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"))
+                       .with_stdout_contains("test result: FAILED. [..]")
+                       .with_stdout_contains("test sub_one_test ... ok")
+                       .with_stdout_contains_n("test [..] ... ok", 3));
 }
 
 #[test]
@@ -2297,18 +1969,9 @@ fn test_multiple_packages() {
                 execs().with_status(0)
                        .with_stderr_contains("\
 [RUNNING] target[/]debug[/]deps[/]d1-[..][EXE]")
-                       .with_stdout_contains("
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-")
                        .with_stderr_contains("\
 [RUNNING] target[/]debug[/]deps[/]d2-[..][EXE]")
-                       .with_stdout_contains("
-running 0 tests
-
-test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-"));
+                       .with_stdout_contains_n("running 0 tests", 2));
 }
 
 #[test]
@@ -2435,13 +2098,7 @@ fn only_test_docs() {
 [COMPILING] foo v0.0.1 ([..])
 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
 [DOCTEST] foo")
-                       .with_stdout("
-running 1 test
-test [..] ... ok
-
-test result: ok.[..]
-
-"));
+                       .with_stdout_contains("test [..] ... ok"));
 }
 
 #[test]
@@ -2715,20 +2372,9 @@ fn test_all_workspace() {
 
     assert_that(p.cargo_process("test")
                  .arg("--all"),
-                execs().with_status(0).with_stdout_contains("\
-running 1 test
-test foo_test ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-")
-                       .with_stdout_contains("\
-running 1 test
-test bar_test ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                execs().with_status(0)
+                       .with_stdout_contains("test foo_test ... ok")
+                       .with_stdout_contains("test bar_test ... ok"));
 }
 
 #[test]
@@ -2759,20 +2405,9 @@ fn test_all_virtual_manifest() {
 
     assert_that(p.cargo_process("test")
                  .arg("--all"),
-                execs().with_status(0).with_stdout_contains("\
-running 1 test
-test b ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-")
-                .with_stdout_contains("\
-running 1 test
-test b ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                execs().with_status(0)
+                       .with_stdout_contains("test a ... ok")
+                       .with_stdout_contains("test b ... ok"));
 }
 
 #[test]
@@ -2799,13 +2434,8 @@ fn test_all_member_dependency_same_name() {
 
     assert_that(p.cargo_process("test")
                  .arg("--all"),
-                execs().with_status(0).with_stdout_contains("\
-running 1 test
-test a ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
-"));
+                execs().with_status(0)
+                       .with_stdout_contains("test a ... ok"));
 }
 
 #[test]
@@ -2956,13 +2586,10 @@ fn cargo_test_env() {
     let mut pr = p.cargo_process("test");
     let cargo = cargo_exe().canonicalize().unwrap();
     assert_that(pr.args(&["--lib", "--", "--nocapture"]),
-                execs().with_status(0).with_stdout(format!("
-running 1 test
+                execs().with_status(0)
+                       .with_stdout_contains(format!("\
 {}
 test env_test ... ok
-
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
-
 ", cargo.to_str().unwrap())));
 }
 
@@ -2985,23 +2612,24 @@ fn test_order() {
         "#);
 
         assert_that(p.cargo_process("test").arg("--all"),
-            execs().with_status(0).with_stdout_contains("\
+            execs().with_status(0)
+                   .with_stdout_contains("
 running 1 test
 test test_lib ... ok
 
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
+test result: ok. [..]
 
 
 running 1 test
 test test_a ... ok
 
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
+test result: ok. [..]
 
 
 running 1 test
 test test_z ... ok
 
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
+test result: ok. [..]
 "));
 
 }